<template>
	<view>
		<u-navbar title-color="#ffffff" title="城市合伙人" back-text="返回" back-icon-color="#ffffff"
			:back-text-style="textObj" :border-bottom="false" :background="background"></u-navbar>
		<!-- <view class="main-mask">
			<view class="mask-box"></view>
		</view> -->
		<view class="main">
			<view class="box">
				<view class="">余额</view>
				<view class="">{{currentPartnerFee}}</view>
			</view>
			<!-- <view class="box">
				<view class="">待分金额</view>
				<view class="">{{waitProceedPartnerFee}}</view>
				<view class="line"></view>
			</view> -->
			<view class="btn" @click="approveStatus ? $u.route('/pages/user/withdrawal/withdrawal',{
			currentEnableFee:currentPartnerFee,
			cashType:15,
			typeText:'城市合伙人'
		}) : approvePopup = true">
				<view>提现</view>
			</view>
		</view>
		<view class="screen-plate">
			<view class="screen-time">查询时间:{{currentTime}}</view>
			<view class="screen-time-option" @tap="openData"><u-image width="32rpx" height="32rpx"
					:src="appletImgUrl+'cate_tow.png'"></u-image>
				<view class="screen-time-label">筛选</view>
			</view>
		</view>
		<view class="data-list">
			<view class="list-li" v-for="(item,index) in recordList" :key="index">
				<view class="li-top">
					<view class="li-top-left">金额类型：</view>
					<view class="li-top-right" style="color: #E42548;font-weight: bold;">{{item.feeTypeName?item.feeTypeName:"城市合伙人分润"}}</view>
				</view>
				<view class="li-top">
					<view class="li-top-left">金额：</view>
					<view class="li-top-right" style="color: #E42548;font-weight: bold;">{{item.processFee}}</view>
				</view>
				<view class="li-bottom">
					<view class="li-bottom-left">时间</view>
					<view class="li-bottom-right">{{item.addTime}}</view>
				</view>
				<!-- <view class="li-bottom">
					<view class="li-bottom-left">状态</view>
					<view class="li-bottom-right" v-if="item.status==10">待分润</view>
					<view class="li-bottom-right" v-if="item.status==20">已分润</view>
				</view> -->
				
			</view>
		</view>
		<u-loadmore :status="status" />
		<u-calendar v-model="show" :mode="mode" @change="change"></u-calendar>

		<u-modal confirm-text="去认证" show-cancel-button confirm-color="#FD5C1D" v-model="approvePopup" @confirm="$u.route('/pages/user/realName/realName',{
			realState: realState
		})" content="您得先实名认证了才可以提现"></u-modal>
	</view>
</template>

<script>
	import {
		imgUrl,
		appletImgUrl
	} from "@/common/config.js"
	let uTabOffsetTop = 44 + uni.getSystemInfoSync().statusBarHeight
	export default {
		data() {
			return {
				appletImgUrl: appletImgUrl,
				defaultTime: '',
				showTip: true,
				current: 0,
				approveStatus: false,
				type: ['收入明细'],
				realState: '',
				typeIndex: 1,
				imageURL: this.imageURL,
				status: 'loading',
				approvePopup: false,
				waitProceedPartnerFee: 0,
				params: {
					year: true,
					month: true
				},
				show: false,
				currentPartnerFee: 0,
				currentMallFee: 0,

				textObj: {
					color: '#ffffff'
				},
				list: [],
				fail: false,
				currentDate: '',
				firstDatetime: '',
				lastDatetime: '',
				background: {
					backgroundImage: 'linear-gradient(90deg, rgba(255, 77, 70, 1), rgba(255, 162, 0, 1))'
				},
				model: {
					pageNo: 1,
					pageSize: 10,
					startTime: "",
					endTime: "",
					feeType:9
				},
				pageTotal: 1,
				public: {
					startTime: "",
					endTime: ""
				},
				currentTime: "",
				user_info: {},
				recordList: [],
				status: "loadmore",
				mode: "range",
				show: false,
				count:0
			};
		},
		onLoad() {
			this.user_info = uni.getStorageSync('userInfo');
			console.log(this.user_info)
			// this.model.userId = this.user_info.id;
			// this.model.userName = this.user_info.userName;


			this.$u.get('userwallet/info').then(res => {
				this.currentPartnerFee = res.currentCityPartnerFee;
				//this.waitProceedPartnerFee = res.currentOutlineFee

			})
			this.$u.get('userverify/ok').then(res => {
				switch (res.approveStatus) {
					case 20:
						this.approveStatus = true
						break
					case 10:
						this.realState = 1
						break
				}
				if (!res.approveStatus) {
					this.realState = 0
				}
			})
			this.getTime();
			this.getIncomeList()


		},
		onReachBottom() {
			if (this.count>=10) {
				this.status = 'loading';
				this.model.pageNo++
				this.getIncomeList();
			} else {
				this.status = 'nomore'
			}

		},
		methods: {
			getIncomeList() {
				this.$u.post('userwallet/statisticsWalletLogDetail', this.model).then(res => {
					console.log(res)
					this.recordList =[...res.list,...this.recordList];
					this.count=res.list.length;
					if(this.count>=10){
						this.status = 'loading';
					}else{
						this.status = 'nomore';
					}
					
				})
			},
			getTime() {
				let now = new Date();
				let year = now.getFullYear(); // 年
				let month = now.getMonth() + 1; // 月
				let date = now.getDate(); // 日
				let yesterday = new Date(now); // 通过复制今天的日期创建一个新的日期对象
				   yesterday.setDate(now.getDate() - 1); // 将新日期对象的日期减去一天
				let yesYear=yesterday.getFullYear();
				let yesMonth=yesterday.getMonth() + 1;
				let yesDate=yesterday.getDate();
				if (month < 10) {
					month = "0" + month;
				}
				if (date < 10) {
					date = "0" + date;
				}
                if (yesMonth < 10) {
                	yesMonth = "0" + yesMonth;
                }
                if (yesDate < 10) {
                	yesDate = "0" + yesDate;
                }
				this.public.startTime = yesYear+"-"+yesMonth+"-"+yesDate+" 00:00:00";
				this.public.endTime = year + "-" + month + "-"+date+" 23:59:59";
				this.currentTime = yesYear + "-" + yesMonth +"-"+ yesDate + "至" + year + "-" + month + "-" + date;
				this.model.startTime = yesYear+"-"+yesMonth+"-"+yesDate+" 00:00:00";
				this.model.endTime = year + "-" + month + "-"+date+" 23:59:59";

			},
			openData() {
				this.show = true;
			},
			change(e) {
				console.log(e);
				this.public.startTime = e.startDate + ' ' + '00:00:00';
				this.public.endTime = e.endDate + ' ' + '23:59:59';
				this.model.startTime = this.public.startTime;
				this.model.endTime = this.public.endTime;
				this.currentTime = e.startDate + "至" + e.endDate;
				this.model.pageNo = 1;
				this.pageTotal = 1;
				this.recordList = [];
				this.count=0;
				this.getIncomeList();
			},

		}
	}
</script>

<style lang="scss">
	// .btn {
	// 	position: fixed;
	// 	width: 100%;
	// 	bottom: 0;
	// 	z-index: 2;
	// 	left: 0;
	// 	background: linear-gradient(90deg, #FD5C1D, #FD9B1D);
	// 	border-radius: 40rpx 40rpx 0 0;
	// 	.btn-box {
	// 		line-height: 100rpx;
	// 		color: #FFFFFF;
	// 		text-align: center;
	// 		font-size: 28rpx;
	// 	}
	// }

	.container {
		position: relative;
		z-index: 1;
		top: -35rpx;

		.content {
			border-radius: 40rpx 40rpx 0px 0px;
			background-color: #FFFFFF;
			padding: 0 30rpx;

			.choice-date {
				color: #AAAAAA;
				font-size: 26rpx;
				padding-top: 34rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
			}

			.list {
				// padding-bottom: 65rpx;
				min-height: 50vh;

				.loading {
					display: flex;
					justify-content: center;
					padding-top: 300rpx;
				}

				.item {
					border-top: 1rpx solid #E1E0E0;
					padding: 30rpx 0;

					&:first-child {
						border-top: none;
					}

					.item-list {
						margin-top: 30rpx;

						>view {
							display: flex;
							margin-top: 5rpx;
							align-items: center;
							justify-content: space-between;
						}

						.user {
							justify-content: flex-start;
							margin-bottom: 25rpx;

							.name {
								margin-left: 15rpx;
							}
						}
					}

					.other {
						display: flex;
						align-items: center;
						justify-content: space-between;

						view {
							&:first-child {
								font-weight: bold;
								font-size: 28rpx;
							}

							&:last-child {
								text {
									color: #FF4D46;
									font-size: 48rpx;
									font-weight: bold;
								}
							}
						}
					}
				}
			}

			// .money {
			// 	view {
			// 		&:first-child {
			// 			font-size: 24rpx;
			// 		}

			// 		&:last-child {
			// 			font-weight: bold;
			// 			font-size: 30rpx;

			// 			text {
			// 				font-size: 48rpx;
			// 			}
			// 		}
			// 	}
			// }

			.tab {
				height: 82rpx;
				border-bottom: 1rpx solid #E1E0E0;
			}

			.title {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 45rpx 0;
				border-bottom: 1rpx solid #E1E0E0;

				.right {
					&:last-child {
						// padding: 5rpx 15rpx;
						display: flex;
						// border: 1rpx solid #E1E0E0;
						// border-radius: 4rpx;
						align-items: center;

						text {
							margin-left: 10rpx;
							color: #AAAAAA;
							font-size: 26rpx;
						}
					}

					&:first-child {
						font-weight: bold;
						font-size: 32rpx;
					}
				}

				.left {
					display: flex;
					align-items: center;

					>view {
						color: #AAAAAA;
						position: relative;

						.icon {
							position: absolute;
							bottom: -45rpx;
							left: 50%;
							transform: translateX(-50%);
							width: 44rpx;
							height: 6rpx;
							background: linear-gradient(90deg, #FF7200, #FECD62);
							border-radius: 3rpx;
						}

						&.active {
							font-size: 36rpx;
							color: #000000;
							font-weight: bold;
						}

						&:last-child {
							// margin-left: 40rpx;
						}
					}
				}
			}
		}
	}

	.main-mask {
		background: linear-gradient(90deg, #FF4D46, #FFA200);
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		height: 50%;
	}

	.main {
		display: flex;
		position: relative;
		padding-bottom: 70rpx;
		background: linear-gradient(90deg, #FF4D46, #FFA200);

		.btn {
			margin-top: 20rpx;
			display: flex;
			justify-content: center;
			position: absolute;
			bottom: 60rpx;
			left: 50%;
			transform: translateX(-50%);

			view {
				border: 1rpx solid #fff;
				border-radius: 10rpx;
				color: #fff;
				// width: 140rpx;
				line-height: 54rpx;
				padding: 0 45rpx;
			}
		}

		.box {
			text-align: center;
			padding-bottom: 75rpx;
			padding-top: 30rpx;
			flex: 1;
			position: relative;



			.line {
				position: absolute;
				top: 50%;
				left: 0;
				transform: translateY(-50%);
				width: 1rpx;
				height: 65rpx;
				background-color: rgba($color: #ffffff, $alpha: .5);
				margin-top: -20rpx;
			}

			view {
				color: #FFFFFF;

				&:first-child {
					font-size: 24rpx;
				}

				&:nth-child(2) {
					font-size: 60rpx;
					font-weight: bold;
					// margin: 10rpx 0;
					margin-top: 5rpx;
					// margin-bottom: 15rpx;
				}

				// &:last-child {
				// 	display: flex;
				// 	justify-content: center;

				// 	navigator {
				// 		font-size: 24rpx;
				// 		border: 1rpx solid #FFFFFF;
				// 		color: #FFFFFF;
				// 		line-height: 56rpx;
				// 		border-radius: 10rpx;
				// 		// width: 170rpx;
				// 		padding: 0 60rpx;
				// 	}
				// }
			}
		}
	}

	.screen-plate {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		padding-left: 30rpx;
		padding-right: 30rpx;
		margin-top: 40rpx;
		margin-bottom: 20rpx;

		.screen-time-option {
			display: flex;
			flex-direction: row;
			justify-content: flex-start;

			.screen-time-label {
				margin-left: 10rpx;
			}
		}
	}

	.data-list {
		padding-left: 30rpx;
		padding-right: 30rpx;

		.list-li {
			padding: 20rpx;
			background: #F4F5F7;
			border-radius: 20rpx;
			margin-bottom: 20rpx;

			.li-top {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				margin-bottom: 10rpx;
			}

			.li-bottom {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				margin-top: 4rpx;
			}
		}
	}
</style>